
#pragma once

#include <math.h>
#include <float.h>
#include <memory.h>
#include <malloc.h>
#include <stdio.h>

typedef unsigned int	u32;
typedef unsigned short	u16;
typedef unsigned char	u8;

#define NULL 0
#define FALSE 0
#define TRUE 1

namespace Blox
{
	inline float FDiv ( float a, float b ) { return b!=0?a/b:FLT_MAX; }
	inline float FSqrt ( float a ) { return sqrtf(a); }
	inline float FLerp ( float a, float b, float t ) { return a+((b-a)*t); }
	inline float FMin ( float a, float b ) { return a<b?a:b; }
	inline float FMax ( float a, float b ) { return a<b?b:a; }
}

union Col32
{
	u32 c32;
	u8 c8[4];
};

namespace Col
{
	static Col32 const BLACK = { 0xFF000000 };
	static Col32 const WHITE = { 0xFFFFFFFF };
}

class ColF_RGBA
{
public:
	ColF_RGBA ( ) : r(1.0f), g(1.0f), b(1.0f), a(1.0f) { }
	ColF_RGBA ( Col32 _col ) { Set(_col); }
	ColF_RGBA ( u32 _col ) { Col32 __col = {_col}; Set(__col); }

	inline float * AsFloatArray ( ) const { return ((float*)&r); }
	inline void Set ( Col32 uCol ) { r=((float)uCol.c8[0])/255.0f; g=((float)uCol.c8[1])/255.0f; b=((float)uCol.c8[2])/255.0f; a=((float)uCol.c8[3])/255.0f; }

	float r;
	float g;
	float b;
	float a;
};

